package com.qzdatasoft.mcp.server.demo.repository;

import com.qzdatasoft.mcp.server.demo.entity.User;
import lombok.Data;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@Data
public class UserRepository {

    private final List<User> users  = new ArrayList<>();

    public User add(User user){
        if(0 == user.getId()) {
            user.setId(users.size() + 1);
        }
        users.add(user);

        return user;
    }

    {
        users.addAll(List.of(
                new User(Integer.MAX_VALUE - 1, "张三", "18"),
                new User(Integer.MAX_VALUE - 2, "李四", "19"),
                new User(Integer.MAX_VALUE - 3, "王五", "20")
        ));
    }

}
